//
//  NSArray+Renew.m
//  UStarter
//
//  Created by Mark on 2021/1/8.
//

#import "NSArray+Renew.h"

@implementation NSArray (Renew)

- (NSArray*)enumarateForBlock:(RenewArrayBlock)block {
    NSMutableArray * arr = [NSMutableArray arrayWithCapacity:self.count];
    NSInteger index = 0;
    id val ;
    NSEnumerator * enumerator =[self objectEnumerator];
    while (val = [enumerator nextObject] ) {
        [arr addObject:block(val,index++,self)];
    }
    return arr ;
}

- (NSArray*)enumarateForFilterBlock:(RenewFilterBlick)block {
    NSMutableArray * arr = [NSMutableArray array];
    NSInteger index = 0;
    id val ;
    NSEnumerator * enumerator =[self objectEnumerator];
    while (val = [enumerator nextObject] ) {
        BOOL need = block(val,index++,self);
        if(need){
            [arr addObject:val];
        }
    }
    return arr ;
}

@end
